package com.llg.controller;

import com.llg.model.BrandModel;
import com.llg.model.response.DataResult;
import com.llg.model.response.PageResult;
import com.llg.model.response.ResponseResult;
import com.llg.pojo.LedBrand;
import com.llg.service.LedBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/LedBrand")
public class LedBrandController {

    @Autowired
    private LedBrandService brandService;

    //查询所有品牌信息
    @GetMapping("/findAll")
    public PageResult<BrandModel> findAll(){
        return brandService.findAll();
    }

    //搜索并分页查询
    @PostMapping("/findList")
    public PageResult<BrandModel> findList(Integer currentPage,Integer pageSize,@RequestBody LedBrand ledBrand){
        return brandService.findPage(currentPage, pageSize, ledBrand);
    }

    //根据id查询品牌信息
    @GetMapping("/{id}")
    public DataResult<BrandModel> findById(@PathVariable("id") Integer id){
        return brandService.findById(id);
    }

    //添加品牌信息
    @PostMapping("/add")
    public DataResult<BrandModel> add(@RequestBody LedBrand brand){
        return brandService.save(brand);
    }

    //修改品牌信息
    @PostMapping("/update")
    public ResponseResult update(@RequestBody LedBrand brand){
        return brandService.update(brand);
    }

    //删除品牌信息
    @GetMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return brandService.remove(id);
    }

}
